package httpserver

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

//GinHandle 支持转换为gin框架的hanler
func GinHandle(f func(ctx *Ctx)) func(c *gin.Context) {

	return func(c *gin.Context) {
		ctx := NewCtx(c.Writer, c.Request)
		ctx.setGin(c)

		f(ctx)
	}
}

//EmptyHandle 空处理
func EmptyHandle(ctx *Ctx) {
	ctx.writer.WriteHeader(http.StatusNoContent)
	return
}

var EmptyHandler = new(emptyHandler)

//空处理器
type emptyHandler int
func (h *emptyHandler) ServeHTTP(w http.ResponseWriter, request *http.Request) {
	w.WriteHeader(http.StatusNoContent)
	return
}
